import 'package:flutter/material.dart';
import 'package:kq_flutter_core_widget/utils/kq_screen_util.dart';
import 'package:get/get.dart';
import 'package:kq_flutter_widgets/resources/kq_theme_colors.dart';
import 'package:kq_flutter_core_widget/utils/toast_util.dart';
import 'package:kq_flutter_widgets/widgets/button/kq_bottom_button.dart';
import 'package:kq_flutter_widgets/widgets/button/kq_checked_button.dart';
import 'package:kq_flutter_widgets/widgets/button/kq_count_down_button.dart';
import 'package:kq_flutter_widgets/widgets/button/kq_head_button.dart';
import 'package:kq_flutter_widgets/widgets/button/kq_icon_button.dart';
import 'package:kq_flutter_widgets/widgets/button/kq_icon_text_group_button.dart';
import 'package:kq_flutter_core_widget/widgets/button/kq_ink_well.dart';
import 'package:kq_flutter_widgets/widgets/button/kq_outline_button.dart';
import 'package:kq_flutter_widgets/widgets/button/kq_small_button.dart';
import 'package:kq_flutter_widgets/widgets/button/kq_swith_button.dart';
import 'package:kq_flutter_widgets/widgets/button/kq_underline_button.dart';
import 'package:kq_flutter_widgets/widgets/expandableList/kq_expand_group.dart';
import 'package:kq_flutter_widgets/widgets/titleBar/kq_title_bar.dart';

import '../../resources/Images.dart';

/// 按钮演示
class ButtonDemoPage extends StatefulWidget {
  const ButtonDemoPage({Key? key}) : super(key: key);

  @override
  ButtonDemoPageState createState() => ButtonDemoPageState();
}

class ButtonDemoPageState extends State<ButtonDemoPage> {
  var checked = false;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: KqHeadBar(
        headTitle: '通用按钮演示',
        back: () {
          Get.back();
        },
      ),
      body: SingleChildScrollView(
        child: Column(
          children: [
            KqExpandGroup(
                headerWidget: Text(
                  'KqBottomButton',
                  style:
                      TextStyle(fontSize: 14.sp, color: KqThemeColors.text26),
                ),
                childWidgets: [
                  KqBottomButton(
                    title: '提交',
                    onTap: (disabled) => KqToast.showNormal('提交'),
                  ),
                  KqBottomButton(
                    title: '提交',
                    disabled: true,
                    onTap: (disabled) => KqToast.showNormal('提交'),
                  ),
                  KqBottomButton.normal(
                    title: '提交',
                    onTap: (disabled) => KqToast.showNormal('提交'),
                  )
                ]),
            KqExpandGroup(
                headerWidget: Text(
                  'KqOutlineButton',
                  style:
                      TextStyle(fontSize: 14.sp, color: KqThemeColors.text26),
                ),
                childWidgets: [
                  Padding(
                    padding: EdgeInsets.all(12.r),
                    child: Row(
                      children: [
                        KqOutlineButton(
                          title: '撤回',
                        ),
                        SizedBox(
                          width: 10.r,
                          height: 1.r,
                        ),
                        KqOutlineButton(
                          title: '编辑',
                        ),
                        SizedBox(
                          width: 10.r,
                          height: 1.r,
                        ),
                        KqOutlineButton.normal(
                          title: '操作按钮',
                        ),
                      ],
                    ),
                  )
                ]),
            KqExpandGroup(
                headerWidget: Text(
                  'KqIconButton',
                  style:
                      TextStyle(fontSize: 14.sp, color: KqThemeColors.text26),
                ),
                childWidgets: [
                  Container(
                    color: KqThemeColors.bgWhite,
                    padding: EdgeInsets.all(12.r),
                    child: Row(
                      children: [
                        KqIconButton(
                          icon: Image.asset(
                            Images.homeIcTouxiang,
                            width: 40.r,
                            height: 40.r,
                          ),
                          onPressed: () {
                            KqToast.showNormal('111');
                          },
                        ),
                        KqIconButton(
                          size: 40.r,
                          icon: Icon(
                            Icons.search,
                            size: 20.r,
                            color: KqThemeColors.bgBlue,
                          ),
                          onPressed: () {
                            KqToast.showNormal('111');
                          },
                        ),
                        KqIconButton(
                          size: 30.r,
                          icon: Icon(
                            Icons.search,
                            size: 20.r,
                          ),
                          onPressed: () {
                            KqToast.showNormal('111');
                          },
                        ),
                      ],
                    ),
                  ),
                ]),
            KqExpandGroup(
                headerWidget: Text(
                  'KqSwitchButton',
                  style:
                      TextStyle(fontSize: 14.sp, color: KqThemeColors.text26),
                ),
                childWidgets: [
                  Padding(
                    padding: EdgeInsets.all(12.r),
                    child: Row(
                      children: [
                        Text(
                          '自定义大小:',
                          style: TextStyle(fontSize: 12.sp),
                        ),
                        KqSwitchButton(
                            value: checked,
                            onChanged: (value) {
                              setState(() {
                                checked = value;
                              });
                            }),
                        KqSwitchButton(
                            value: checked,
                            size: Size(50.r, 30.r),
                            onChanged: (value) {
                              setState(() {
                                checked = value;
                              });
                            }),
                        KqSwitchButton(
                            value: checked,
                            size: Size(60.r, 40.r),
                            onChanged: (value) {
                              setState(() {
                                checked = value;
                              });
                            }),

                        /// 不可点击示例
                        Text(
                          '不可点击:',
                          style: TextStyle(fontSize: 12.sp),
                        ),
                        KqSwitchButton(
                            value: checked,
                            size: Size(60.r, 40.r),
                            disabled: true,
                            onChanged: (value) {
                              setState(() {
                                checked = value;
                              });
                            }),
                      ],
                    ),
                  ),
                ]),
            KqExpandGroup(
                headerWidget: Text(
                  'KqUnderlineButton',
                  style:
                      TextStyle(fontSize: 14.sp, color: KqThemeColors.text26),
                ),
                childWidgets: [
                  Padding(
                    padding: EdgeInsets.all(12.r),
                    child: Row(
                      children: [
                        KqUnderlineButton(
                          title: '下划线按钮',
                        )
                      ],
                    ),
                  ),
                ]),
            KqExpandGroup(
                headerWidget: Text(
                  'KqSmallButton',
                  style:
                      TextStyle(fontSize: 14.sp, color: KqThemeColors.text26),
                ),
                childWidgets: [
                  Padding(
                    padding: EdgeInsets.all(12.r),
                    child: Row(
                      children: [
                        const KqSmallButton(
                          title: '编辑',
                        ),
                        SizedBox(
                          width: 10.r,
                          height: 1.r,
                        ),
                        const KqSmallButton(
                          title: '自动生成',
                          disabled: true,
                        )
                      ],
                    ),
                  ),
                ]),
            KqExpandGroup(
                headerWidget: Text(
                  'KqCountDownButton',
                  style:
                      TextStyle(fontSize: 14.sp, color: KqThemeColors.text26),
                ),
                childWidgets: [
                  Padding(
                    padding: EdgeInsets.all(12.r),
                    child: Row(
                      children: [
                        KqCountDownButton(
                          countDownValue: 10,
                          onTap: (state) {
                            state.startTimer();
                          },
                          textBuilder: (state, value) {
                            return Text("发送验证码：（$value）");
                          },
                        ),
                      ],
                    ),
                  ),
                ]),
            KqExpandGroup(
                headerWidget: Text(
                  'KqHeadButton',
                  style:
                      TextStyle(fontSize: 14.sp, color: KqThemeColors.text26),
                ),
                childWidgets: [
                  KqHeadBar(
                    headTitle: '标题',
                    actions: [
                      KqHeadButton(
                        buttonType: KqHeadButtonType.icon,
                        widget:
                            Icon(Icons.more_vert, color: KqThemeColors.bgWhite),
                        onTap: () {},
                        menuData: [KqPopMenuItemData(title: 'xxx')],
                      ),
                    ],
                  ),
                  KqHeadBar(
                    headTitle: '标题',
                    actions: [
                      KqHeadButton(
                        buttonType: KqHeadButtonType.text,
                        widget: Text('更多'),
                        onTap: () {},
                      ),
                    ],
                  ),
                  KqHeadBar(
                    headTitle: '标题',
                    actions: [
                      KqHeadButton.child(
                        widget: Row(
                          mainAxisSize: MainAxisSize.min,
                          children: [
                            Text(
                              '更多',
                              style: TextStyle(
                                fontSize: 14.sp,
                              ),
                            ),
                            Icon(Icons.more_vert, color: KqThemeColors.bgWhite),
                          ],
                        ),
                        onTap: () {},
                        menuData: [KqPopMenuItemData(title: 'xxx')],
                      ),
                    ],
                  )
                ]),
            KqExpandGroup(
                headerWidget: Text(
                  'KqInkWell',
                  style:
                      TextStyle(fontSize: 14.sp, color: KqThemeColors.text26),
                ),
                childWidgets: [
                  Padding(
                    padding: EdgeInsets.all(12.r),
                    child: Row(
                      children: [
                        KqInkWell(
                          child: Icon(Icons.search),
                          horizontalPadding: 5.r,
                          verticalPadding: 5.r,
                          radius: 100.r,
                          onTap: () {},
                        ),
                        KqInkWell(
                          child: Icon(
                            Icons.search,
                            color: KqThemeColors.bgWhite,
                          ),
                          backgroundColor: KqThemeColors.bgBlue,
                          horizontalPadding: 5.r,
                          verticalPadding: 5.r,
                          radius: 10.r,
                          onTap: () {},
                        )
                      ],
                    ),
                  )
                ]),
            KqExpandGroup(
                headerWidget: Text(
                  'KqCheckedButton',
                  style:
                      TextStyle(fontSize: 14.sp, color: KqThemeColors.text26),
                ),
                childWidgets: [
                  Padding(
                    padding: EdgeInsets.all(12.r),
                    child: Row(
                      children: [
                        KqCheckedButton(
                          isChecked: false,
                          checkedString: '全不选',
                          unCheckedString: '全选',
                          onCheckedChanged: (checked) {
                            KqToast.showNormal("checked=$checked");
                          },
                        ),
                      ],
                    ),
                  )
                ]),
            KqExpandGroup(
                headerWidget: Text(
                  'KqIconTextGroupButton',
                  style:
                      TextStyle(fontSize: 14.sp, color: KqThemeColors.text26),
                ),
                childWidgets: [
                  Padding(
                    padding: EdgeInsets.all(12.r),
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.spaceAround,
                      children: [
                        KqIconTextGroupButton(
                          type: IconTextType.iconTextVerticalType,
                          icon: Image.asset(
                            Images.homeIcTouxiang,
                            width: 40.r,
                            height: 40.r,
                          ),
                          text: const Text('头像'),
                          onTap: () =>
                              KqToast.showNormal('iconTextVerticalType被点击了'),
                        ),
                        KqIconTextGroupButton(
                          type: IconTextType.textIconVerticalType,
                          icon: Image.asset(
                            Images.homeIcTouxiang,
                            width: 40.r,
                            height: 40.r,
                          ),
                          text: const Text('头像'),
                          onTap: () =>
                              KqToast.showNormal('textIconVerticalType被点击了'),
                        ),
                        KqIconTextGroupButton(
                          type: IconTextType.iconTextHorizontalType,
                          icon: Image.asset(
                            Images.homeIcTouxiang,
                            width: 40.r,
                            height: 40.r,
                          ),
                          text: const Text('头像'),
                          onTap: () =>
                              KqToast.showNormal('iconTextHorizontalType被点击了'),
                        ),
                        KqIconTextGroupButton(
                          type: IconTextType.textIconHorizontalType,
                          icon: Image.asset(
                            Images.homeIcTouxiang,
                            width: 40.r,
                            height: 40.r,
                          ),
                          text: const Text('头像'),
                          onTap: () =>
                              KqToast.showNormal('textIconHorizontalType被点击了'),
                        ),
                      ],
                    ),
                  )
                ])
          ],
        ),
      ),
    );
  }
}
